package com.mlj.ship

import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowManager
import android.widget.Button

class MainActivity : AppCompatActivity(), View.OnClickListener {

    private var startBtn: Button? = null
    private var exitBtn: Button? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main)
        if (Build.VERSION.SDK_INT >= 21) {
            val decorView = window.decorView
            val option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            decorView.systemUiVisibility = option
            window.statusBarColor = Color.TRANSPARENT
        }
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) //保持屏幕常亮
        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
        findView()
        startBtn!!.setOnClickListener(this)
        exitBtn!!.setOnClickListener { System.exit(0) }

    }

    private fun findView() {
        startBtn = findViewById(R.id.start_btn) as Button
        exitBtn = findViewById(R.id.exit_btn) as Button
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.start_btn -> {
                startActivity(Intent(this@MainActivity, GameActivity::class.java))
                finish()
            }
        }
    }
}
